#! /usr/bin/python

import math
import time

t = time.time()

length = 5*10**7

def sieve(n):
    ll = range(n)
    for i in range(2, int(math.sqrt(n)) + 1):
	for j in range(i**2, n, i):
	    ll[j] = 0
    return [p for p in ll if p != 0]

ll = sieve(length)
total = 0
for i in range(1, len(ll)):
    if ll[i] != 0: 
       if (ll[i]+1)%4 == 0: total += 1
       if ll[i]*4 < length: total += 1
       if ll[i]*16 < length: total += 1
       #print ll[i], total
       #print i
       #print i

print total, length - ll.count(0) - 1
print time.time() - t
